home *** CD-ROM | disk | FTP | other *** search
/ Macwelt 4 / Macwelt DVD 4.cdr / Entwickler / Mac-OS / oxygen / samples / docbook / xsl / html / xref.xsl < prev   
Encoding:
Extensible Markup Language  |  2002-09-09  |  22.0 KB  |  654 lines  |  [□□□□/□□□□]

  1. xref.xslU≈π¢tÚπ¢tÚÅÅÆ<?xml version='1.0'?>
  2. <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  3.                 xmlns:doc="http://nwalsh.com/xsl/documentation/1.0"
  4.                 exclude-result-prefixes="doc"
  5.                 version='1.0'>
  6.  
  7. <!-- ********************************************************************
  8.      $Id: xref.xsl,v 1.1 2002/05/29 09:55:49 dan Exp $
  9.      ********************************************************************
  10.  
  11.      This file is part of the XSL DocBook Stylesheet distribution.
  12.      See ../README or http://nwalsh.com/docbook/xsl/ for copyright
  13.      and other information.
  14.  
  15.      ******************************************************************** -->
  16.  
  17. <!-- ==================================================================== -->
  18.  
  19. <xsl:template match="anchor">
  20.   <xsl:call-template name="anchor"/>
  21. </xsl:template>
  22.  
  23. <!-- ==================================================================== -->
  24.  
  25. <xsl:template match="xref" name="xref">
  26.   <xsl:variable name="targets" select="key('id',@linkend)"/>
  27.   <xsl:variable name="target" select="$targets[1]"/>
  28.   <xsl:variable name="refelem" select="local-name($target)"/>
  29.  
  30.   <xsl:call-template name="check.id.unique">
  31.     <xsl:with-param name="linkend" select="@linkend"/>
  32.   </xsl:call-template>
  33.  
  34.   <xsl:call-template name="anchor"/>
  35.  
  36.   <xsl:choose>
  37.     <xsl:when test="count($target) = 0">
  38.       <xsl:message>
  39.     <xsl:text>XRef to nonexistent id: </xsl:text>
  40.     <xsl:value-of select="@linkend"/>
  41.       </xsl:message>
  42.       <xsl:text>???</xsl:text>
  43.     </xsl:when>
  44.  
  45.     <xsl:when test="$target/@xreflabel">
  46.       <a>
  47.         <xsl:attribute name="href">
  48.           <xsl:call-template name="href.target">
  49.             <xsl:with-param name="object" select="$target"/>
  50.           </xsl:call-template>
  51.         </xsl:attribute>
  52.         <xsl:call-template name="xref.xreflabel">
  53.           <xsl:with-param name="target" select="$target"/>
  54.         </xsl:call-template>
  55.       </a>
  56.     </xsl:when>
  57.  
  58.     <xsl:otherwise>
  59.       <xsl:variable name="href">
  60.         <xsl:call-template name="href.target">
  61.           <xsl:with-param name="object" select="$target"/>
  62.         </xsl:call-template>
  63.       </xsl:variable>
  64.  
  65.       <xsl:choose>
  66.         <xsl:when test="@endterm">
  67.           <xsl:variable name="etargets" select="key('id',@endterm)"/>
  68.           <xsl:variable name="etarget" select="$etargets[1]"/>
  69.           <xsl:choose>
  70.             <xsl:when test="count($etarget) = 0">
  71.               <xsl:message>
  72.                 <xsl:value-of select="count($etargets)"/>
  73.                 <xsl:text>Endterm points to nonexistent ID: </xsl:text>
  74.                 <xsl:value-of select="@endterm"/>
  75.               </xsl:message>
  76.               <a href="{$href}">
  77.                 <xsl:text>???</xsl:text>
  78.               </a>
  79.             </xsl:when>
  80.             <xsl:otherwise>
  81.               <a href="{$href}">
  82.                 <xsl:apply-templates select="$etarget" mode="endterm"/>
  83.               </a>
  84.             </xsl:otherwise>
  85.           </xsl:choose>
  86.         </xsl:when>
  87.  
  88.         <xsl:otherwise>
  89.           <xsl:apply-templates select="$target" mode="xref-to-prefix"/>
  90.  
  91.           <a href="{$href}">
  92.             <xsl:attribute name="title">
  93.               <xsl:apply-templates select="$target" mode="xref-title"/>
  94.             </xsl:attribute>
  95.             <xsl:apply-templates select="$target" mode="xref-to"/>
  96.           </a>
  97.  
  98.           <xsl:apply-templates select="$target" mode="xref-to-suffix"/>
  99.         </xsl:otherwise>
  100.       </xsl:choose>
  101.     </xsl:otherwise>
  102.   </xsl:choose>
  103. </xsl:template>
  104.  
  105. <xsl:template match="*" mode="endterm">
  106.   <!-- Process the children of the endterm element -->
  107.   <xsl:apply-templates select="child::node()"/>
  108. </xsl:template>
  109.  
  110. <!-- ==================================================================== -->
  111.  
  112. <xsl:template match="*" mode="xref-to-prefix"/>
  113. <xsl:template match="*" mode="xref-to-suffix"/>
  114.  
  115. <xsl:template match="*" mode="xref-to">
  116.   <xsl:param name="target" select="."/>
  117.   <xsl:param name="refelem" select="local-name($target)"/>
  118.  
  119.   <xsl:message>
  120.     <xsl:text>Don't know what gentext to create for xref to: "</xsl:text>
  121.     <xsl:value-of select="$refelem"/>
  122.     <xsl:text>", ("</xsl:text>
  123.     <xsl:value-of select="@id"/>
  124.     <xsl:text>")</xsl:text>
  125.   </xsl:message>
  126.   <xsl:text>???</xsl:text>
  127. </xsl:template>
  128.  
  129. <xsl:template match="author" mode="xref-to">
  130.   <xsl:call-template name="person.name"/>
  131. </xsl:template>
  132.  
  133. <xsl:template match="authorgroup" mode="xref-to">
  134.   <xsl:call-template name="person.name.list"/>
  135. </xsl:template>
  136.  
  137. <xsl:template match="figure" mode="xref-to">
  138.   <xsl:apply-templates select="." mode="object.xref.markup"/>
  139. </xsl:template>
  140.  
  141. <xsl:template match="example" mode="xref-to">
  142.   <xsl:apply-templates select="." mode="object.xref.markup"/>
  143. </xsl:template>
  144.  
  145. <xsl:template match="table" mode="xref-to">
  146.   <xsl:apply-templates select="." mode="object.xref.markup"/>
  147. </xsl:template>
  148.  
  149. <xsl:template match="equation" mode="xref-to">
  150.   <xsl:apply-templates select="." mode="object.xref.markup"/>
  151. </xsl:template>
  152.  
  153. <xsl:template match="procedure" mode="xref-to">
  154.   <xsl:apply-templates select="." mode="object.xref.markup"/>
  155. </xsl:template>
  156.  
  157. <xsl:template match="cmdsynopsis" mode="xref-to">
  158.   <xsl:apply-templates select="(.//command)[1]" mode="xref"/>
  159. </xsl:template>
  160.  
  161. <xsl:template match="funcsynopsis" mode="xref-to">
  162.   <xsl:apply-templates select="(.//function)[1]" mode="xref"/>
  163. </xsl:template>
  164.  
  165. <xsl:template match="dedication" mode="xref-to">
  166.   <xsl:apply-templates select="." mode="object.xref.markup"/>
  167. </xsl:template>
  168.  
  169. <xsl:template match="preface" mode="xref-to">
  170.   <xsl:apply-templates select="." mode="object.xref.markup"/>
  171. </xsl:template>
  172.  
  173. <xsl:template match="chapter" mode="xref-to">
  174.   <xsl:apply-templates select="." mode="object.xref.markup"/>
  175. </xsl:template>
  176.  
  177. <xsl:template match="appendix" mode="xref-to">
  178.   <xsl:apply-templates select="." mode="object.xref.markup"/>
  179. </xsl:template>
  180.  
  181. <xsl:template match="bibliography" mode="xref-to">
  182.   <xsl:apply-templates select="." mode="object.xref.markup"/>
  183. </xsl:template>
  184.  
  185. <xsl:template match="biblioentry|bibliomixed" mode="xref-to-prefix">
  186.   <xsl:text>[</xsl:text>
  187. </xsl:template>
  188.  
  189. <xsl:template match="biblioentry|bibliomixed" mode="xref-to-suffix">
  190.   <xsl:text>]</xsl:text>
  191. </xsl:template>
  192.  
  193. <xsl:template match="biblioentry|bibliomixed" mode="xref-to">
  194.   <!-- handles both biblioentry and bibliomixed -->
  195.   <xsl:choose>
  196.     <xsl:when test="string(.) = ''">
  197.       <xsl:variable name="bib" select="document($bibliography.collection)"/>
  198.       <xsl:variable name="id" select="@id"/>
  199.       <xsl:variable name="entry" select="$bib/bibliography/*[@id=$id][1]"/>
  200.       <xsl:choose>
  201.         <xsl:when test="$entry">
  202.           <xsl:choose>
  203.             <xsl:when test="local-name($entry/*[1]) = 'abbrev'">
  204.               <xsl:apply-templates select="$entry/*[1]"/>
  205.             </xsl:when>
  206.             <xsl:otherwise>
  207.               <xsl:value-of select="@id"/>
  208.             </xsl:otherwise>
  209.           </xsl:choose>
  210.         </xsl:when>
  211.         <xsl:otherwise>
  212.           <xsl:message>
  213.             <xsl:text>No bibliography entry: </xsl:text>
  214.             <xsl:value-of select="$id"/>
  215.             <xsl:text> found in </xsl:text>
  216.             <xsl:value-of select="$bibliography.collection"/>
  217.           </xsl:message>
  218.           <xsl:value-of select="@id"/>
  219.         </xsl:otherwise>
  220.       </xsl:choose>
  221.     </xsl:when>
  222.     <xsl:otherwise>
  223.       <xsl:choose>
  224.         <xsl:when test="local-name(*[1]) = 'abbrev'">
  225.           <xsl:apply-templates select="*[1]"/>
  226.         </xsl:when>
  227.         <xsl:otherwise>
  228.           <xsl:value-of select="@id"/>
  229.         </xsl:otherwise>
  230.       </xsl:choose>
  231.     </xsl:otherwise>
  232.   </xsl:choose>
  233. </xsl:template>
  234.  
  235. <xsl:template match="glossary" mode="xref-to">
  236.   <xsl:apply-templates select="." mode="object.xref.markup"/>
  237. </xsl:template>
  238.  
  239. <xsl:template match="index" mode="xref-to">
  240.   <xsl:apply-templates select="." mode="object.xref.markup"/>
  241. </xsl:template>
  242.  
  243. <xsl:template match="listitem" mode="xref-to">
  244.   <xsl:apply-templates select="." mode="object.xref.markup"/>
  245. </xsl:template>
  246.  
  247. <xsl:template match="section|simplesect
  248.                      |sect1|sect2|sect3|sect4|sect5
  249.                      |refsect1|refsect2|refsect3" mode="xref-to">
  250.   <xsl:apply-templates select="." mode="object.xref.markup"/>
  251.   <!-- What about "in Chapter X"? -->
  252. </xsl:template>
  253.  
  254. <xsl:template match="bridgehead" mode="xref-to">
  255.   <xsl:apply-templates select="." mode="object.xref.markup"/>
  256.   <!-- What about "in Chapter X"? -->
  257. </xsl:template>
  258.  
  259. <xsl:template match="qandaset" mode="xref-to">
  260.   <xsl:apply-templates select="." mode="object.xref.markup"/>
  261. </xsl:template>
  262.  
  263. <xsl:template match="qandadiv" mode="xref-to">
  264.   <xsl:apply-templates select="." mode="object.xref.markup"/>
  265. </xsl:template>
  266.  
  267. <xsl:template match="qandaentry" mode="xref-to">
  268.   <xsl:apply-templates select="question[1]" mode="object.xref.markup"/>
  269. </xsl:template>
  270.  
  271. <xsl:template match="question" mode="xref-to">
  272.   <xsl:apply-templates select="." mode="object.xref.markup"/>
  273. </xsl:template>
  274.  
  275. <xsl:template match="answer" mode="xref-to">
  276.   <xsl:apply-templates select="." mode="object.xref.markup"/>
  277. </xsl:template>
  278.  
  279. <xsl:template match="part" mode="xref-to">
  280.   <xsl:apply-templates select="." mode="object.xref.markup"/>
  281. </xsl:template>
  282.  
  283. <xsl:template match="reference" mode="xref-to">
  284.   <xsl:apply-templates select="." mode="object.xref.markup"/>
  285. </xsl:template>
  286.  
  287. <xsl:template match="refentry" mode="xref-to">
  288.   <xsl:choose>
  289.     <xsl:when test="refmeta/refentrytitle">
  290.       <xsl:apply-templates select="refmeta/refentrytitle"/>
  291.     </xsl:when>
  292.     <xsl:otherwise>
  293.       <xsl:apply-templates select="refnamediv/refname[1]"/>
  294.     </xsl:otherwise>
  295.   </xsl:choose>
  296.   <xsl:apply-templates select="refmeta/manvolnum"/>
  297. </xsl:template>
  298.  
  299. <xsl:template match="step" mode="xref-to">
  300.   <xsl:call-template name="gentext">
  301.     <xsl:with-param name="key" select="'Step'"/>
  302.   </xsl:call-template>
  303.   <xsl:text> </xsl:text>
  304.   <xsl:apply-templates select="." mode="number"/>
  305. </xsl:template>
  306.  
  307. <xsl:template match="varlistentry" mode="xref-to">
  308.   <xsl:apply-templates select="term[1]" mode="xref-to"/>
  309. </xsl:template>
  310.  
  311. <xsl:template match="varlistentry/term" mode="xref-to">
  312.   <!-- to avoid the comma that will be generated if there are several terms -->
  313.   <xsl:apply-templates/>
  314. </xsl:template>
  315.  
  316. <xsl:template match="co" mode="xref-to">
  317.   <xsl:apply-templates select="." mode="callout-bug"/>
  318. </xsl:template>
  319.  
  320. <xsl:template match="book" mode="xref-to">
  321.   <xsl:apply-templates select="." mode="object.xref.markup"/>
  322. </xsl:template>
  323.  
  324. <!-- ==================================================================== -->
  325.  
  326. <xsl:template match="*" mode="xref-title">
  327.   <xsl:variable name="title">
  328.     <xsl:apply-templates select="." mode="object.title.markup"/>
  329.   </xsl:variable>
  330.  
  331.   <xsl:value-of select="$title"/>
  332. </xsl:template>
  333.  
  334. <xsl:template match="author" mode="xref-title">
  335.   <xsl:variable name="title">
  336.     <xsl:call-template name="person.name"/>
  337.   </xsl:variable>
  338.  
  339.   <xsl:value-of select="$title"/>
  340. </xsl:template>
  341.  
  342. <xsl:template match="authorgroup" mode="xref-title">
  343.   <xsl:variable name="title">
  344.     <xsl:call-template name="person.name.list"/>
  345.   </xsl:variable>
  346.  
  347.   <xsl:value-of select="$title"/>
  348. </xsl:template>
  349.  
  350. <xsl:template match="cmdsynopsis" mode="xref-title">
  351.   <xsl:variable name="title">
  352.     <xsl:apply-templates select="(.//command)[1]" mode="xref"/>
  353.   </xsl:variable>
  354.  
  355.   <xsl:value-of select="$title"/>
  356. </xsl:template>
  357.  
  358. <xsl:template match="funcsynopsis" mode="xref-title">
  359.   <xsl:variable name="title">
  360.     <xsl:apply-templates select="(.//function)[1]" mode="xref"/>
  361.   </xsl:variable>
  362.  
  363.   <xsl:value-of select="$title"/>
  364. </xsl:template>
  365.  
  366. <xsl:template match="biblioentry|bibliomixed" mode="xref-title">
  367.   <!-- handles both biblioentry and bibliomixed -->
  368.   <xsl:variable name="title">
  369.     <xsl:text>[</xsl:text>
  370.     <xsl:choose>
  371.       <xsl:when test="local-name(*[1]) = 'abbrev'">
  372.         <xsl:apply-templates select="*[1]"/>
  373.       </xsl:when>
  374.       <xsl:otherwise>
  375.         <xsl:value-of select="@id"/>
  376.       </xsl:otherwise>
  377.     </xsl:choose>
  378.     <xsl:text>]</xsl:text>
  379.   </xsl:variable>
  380.  
  381.   <xsl:value-of select="$title"/>
  382. </xsl:template>
  383.  
  384. <xsl:template match="step" mode="xref-title">
  385.   <xsl:call-template name="gentext">
  386.     <xsl:with-param name="key" select="'Step'"/>
  387.   </xsl:call-template>
  388.   <xsl:text> </xsl:text>
  389.   <xsl:apply-templates select="." mode="number"/>
  390. </xsl:template>
  391.  
  392. <xsl:template match="co" mode="xref-title">
  393.   <xsl:variable name="title">
  394.     <xsl:apply-templates select="." mode="callout-bug"/>
  395.   </xsl:variable>
  396.  
  397.   <xsl:value-of select="$title"/>
  398. </xsl:template>
  399.  
  400. <!-- ==================================================================== -->
  401.  
  402. <xsl:template match="link" name="link">
  403.   <xsl:param name="a.target"/>
  404.  
  405.   <xsl:variable name="targets" select="key('id',@linkend)"/>
  406.   <xsl:variable name="target" select="$targets[1]"/>
  407.  
  408.   <xsl:call-template name="check.id.unique">
  409.     <xsl:with-param name="linkend" select="@linkend"/>
  410.   </xsl:call-template>
  411.  
  412.   <a>
  413.     <xsl:if test="@id">
  414.       <xsl:attribute name="name"><xsl:value-of select="@id"/></xsl:attribute>
  415.     </xsl:if>
  416.  
  417.     <xsl:if test="$a.target">
  418.       <xsl:attribute name="target"><xsl:value-of select="$a.target"/></xsl:attribute>
  419.     </xsl:if>
  420.  
  421.     <xsl:attribute name="href">
  422.       <xsl:call-template name="href.target">
  423.         <xsl:with-param name="object" select="$target"/>
  424.       </xsl:call-template>
  425.     </xsl:attribute>
  426.  
  427.     <!-- FIXME: is there a better way to tell what elements have a title? -->
  428.     <xsl:if test="local-name($target) = 'book'
  429.                   or local-name($target) = 'set'
  430.                   or local-name($target) = 'chapter'
  431.                   or local-name($target) = 'preface'
  432.                   or local-name($target) = 'appendix'
  433.                   or local-name($target) = 'bibliography'
  434.                   or local-name($target) = 'glossary'
  435.                   or local-name($target) = 'index'
  436.                   or local-name($target) = 'part'
  437.                   or local-name($target) = 'refentry'
  438.                   or local-name($target) = 'reference'
  439.                   or local-name($target) = 'example'
  440.                   or local-name($target) = 'equation'
  441.                   or local-name($target) = 'table'
  442.                   or local-name($target) = 'figure'
  443.                   or local-name($target) = 'simplesect'
  444.                   or starts-with(local-name($target),'sect')
  445.                   or starts-with(local-name($target),'refsect')">
  446.       <xsl:attribute name="title">
  447.         <xsl:apply-templates select="$target"
  448.                              mode="object.title.markup.textonly"/>
  449.       </xsl:attribute>
  450.     </xsl:if>
  451.  
  452.     <xsl:choose>
  453.       <xsl:when test="count(child::node()) > 0">
  454.         <!-- If it has content, use it -->
  455.         <xsl:apply-templates/>
  456.       </xsl:when>
  457.       <xsl:otherwise>
  458.         <!-- else look for an endterm -->
  459.         <xsl:choose>
  460.           <xsl:when test="@endterm">
  461.             <xsl:variable name="etargets" select="key('id',@endterm)"/>
  462.             <xsl:variable name="etarget" select="$etargets[1]"/>
  463.             <xsl:choose>
  464.               <xsl:when test="count($etarget) = 0">
  465.                 <xsl:message>
  466.                   <xsl:value-of select="count($etargets)"/>
  467.                   <xsl:text>Endterm points to nonexistent ID: </xsl:text>
  468.                   <xsl:value-of select="@endterm"/>
  469.                 </xsl:message>
  470.                 <xsl:text>???</xsl:text>
  471.               </xsl:when>
  472.               <xsl:otherwise>
  473.                   <xsl:apply-templates select="$etarget" mode="endterm"/>
  474.               </xsl:otherwise>
  475.             </xsl:choose>
  476.           </xsl:when>
  477.         
  478.           <xsl:otherwise>
  479.             <xsl:message>
  480.               <xsl:text>Link element has no content and no Endterm. </xsl:text>
  481.               <xsl:text>Nothing to show in the link to </xsl:text>
  482.               <xsl:value-of select="$target"/>
  483.             </xsl:message>
  484.             <xsl:text>???</xsl:text>
  485.           </xsl:otherwise>
  486.         </xsl:choose>
  487.       </xsl:otherwise>
  488.     </xsl:choose>
  489.   </a>
  490. </xsl:template>
  491.  
  492. <xsl:template match="ulink" name="ulink">
  493.   <a>
  494.     <xsl:if test="@id">
  495.       <xsl:attribute name="name">
  496.         <xsl:value-of select="@id"/>
  497.       </xsl:attribute>
  498.     </xsl:if>
  499.     <xsl:attribute name="href"><xsl:value-of select="@url"/></xsl:attribute>
  500.     <xsl:if test="$ulink.target != ''">
  501.       <xsl:attribute name="target">
  502.         <xsl:value-of select="$ulink.target"/>
  503.       </xsl:attribute>
  504.     </xsl:if>
  505.     <xsl:choose>
  506.       <xsl:when test="count(child::node())=0">
  507.     <xsl:value-of select="@url"/>
  508.       </xsl:when>
  509.       <xsl:otherwise>
  510.     <xsl:apply-templates/>
  511.       </xsl:otherwise>
  512.     </xsl:choose>
  513.   </a>
  514. </xsl:template>
  515.  
  516. <xsl:template match="olink" name="olink">
  517.   <xsl:call-template name="anchor"/>
  518.   <xsl:variable name="localinfo" select="@localinfo"/>
  519.  
  520.   <xsl:variable name="href">
  521.     <xsl:choose>
  522.       <xsl:when test="@linkmode">
  523.         <!-- use the linkmode to get the base URI, use localinfo as fragid -->
  524.         <xsl:variable name="modespec" select="key('id',@linkmode)"/>
  525.         <xsl:if test="count($modespec) != 1
  526.                       or local-name($modespec) != 'modespec'">
  527.           <xsl:message>Warning: olink linkmode pointer is wrong.</xsl:message>
  528.         </xsl:if>
  529.         <xsl:value-of select="$modespec"/>
  530.         <xsl:if test="@localinfo">
  531.           <xsl:text>#</xsl:text>
  532.           <xsl:value-of select="@localinfo"/>
  533.         </xsl:if>
  534.       </xsl:when>
  535.       <xsl:when test="@type = 'href'">
  536.         <xsl:call-template name="olink.outline">
  537.           <xsl:with-param name="outline.base.uri"
  538.                           select="unparsed-entity-uri(@targetdocent)"/>
  539.           <xsl:with-param name="localinfo" select="@localinfo"/>
  540.           <xsl:with-param name="return" select="'href'"/>
  541.         </xsl:call-template>
  542.       </xsl:when>
  543.       <xsl:otherwise>
  544.         <xsl:value-of select="$olink.resolver"/>
  545.         <xsl:text>?</xsl:text>
  546.         <xsl:value-of select="$olink.sysid"/>
  547.         <xsl:value-of select="unparsed-entity-uri(@targetdocent)"/>
  548.         <!-- XSL gives no access to the public identifier (grumble...) -->
  549.         <xsl:if test="@localinfo">
  550.           <xsl:text>&</xsl:text>
  551.           <xsl:value-of select="$olink.fragid"/>
  552.           <xsl:value-of select="@localinfo"/>
  553.         </xsl:if>
  554.       </xsl:otherwise>
  555.     </xsl:choose>
  556.   </xsl:variable>
  557.  
  558.   <a href="{$href}">
  559.     <xsl:choose>
  560.       <xsl:when test="count(node()) > 0">
  561.         <xsl:apply-templates/>
  562.       </xsl:when>
  563.       <xsl:otherwise>
  564.         <xsl:call-template name="olink.outline">
  565.           <xsl:with-param name="outline.base.uri"
  566.                           select="unparsed-entity-uri(@targetdocent)"/>
  567.           <xsl:with-param name="localinfo" select="@localinfo"/>
  568.           <xsl:with-param name="return" select="'xref'"/>
  569.         </xsl:call-template>
  570.       </xsl:otherwise>
  571.     </xsl:choose>
  572.   </a>
  573. </xsl:template>
  574.  
  575. <xsl:template name="olink.outline">
  576.   <xsl:param name="outline.base.uri"/>
  577.   <xsl:param name="localinfo"/>
  578.   <xsl:param name="return" select="href"/>
  579.  
  580.   <xsl:variable name="outline-file"
  581.                 select="concat($outline.base.uri,
  582.                                $olink.outline.ext)"/>
  583.  
  584.   <xsl:variable name="outline" select="document($outline-file,.)/div"/>
  585.  
  586.   <xsl:variable name="node-href">
  587.     <xsl:choose>
  588.       <xsl:when test="$localinfo != ''">
  589.         <xsl:variable name="node" select="$outline//*[@id=$localinfo]"/>
  590.         <xsl:value-of select="$node/@href"/>
  591.       </xsl:when>
  592.       <xsl:otherwise>
  593.         <xsl:value-of select="$outline/@href"/>
  594.       </xsl:otherwise>
  595.     </xsl:choose>
  596.   </xsl:variable>
  597.  
  598.   <xsl:variable name="node-xref">
  599.     <xsl:choose>
  600.       <xsl:when test="$localinfo != ''">
  601.         <xsl:variable name="node" select="$outline//*[@id=$localinfo]"/>
  602.         <xsl:copy-of select="$node/xref"/>
  603.       </xsl:when>
  604.       <xsl:otherwise>
  605.         <xsl:value-of select="$outline/xref"/>
  606.       </xsl:otherwise>
  607.     </xsl:choose>
  608.   </xsl:variable>
  609.  
  610.   <xsl:choose>
  611.     <xsl:when test="$return = 'href'">
  612.       <xsl:value-of select="$node-href"/>
  613.     </xsl:when>
  614.     <xsl:when test="$return = 'xref'">
  615.       <xsl:value-of select="$node-xref"/>
  616.     </xsl:when>
  617.     <xsl:otherwise>
  618.       <xsl:copy-of select="$node-xref"/>
  619.     </xsl:otherwise>
  620.   </xsl:choose>
  621. </xsl:template>
  622.  
  623. <!-- ==================================================================== -->
  624.  
  625. <xsl:template name="xref.xreflabel">
  626.   <!-- called to process an xreflabel...you might use this to make  -->
  627.   <!-- xreflabels come out in the right font for different targets, -->
  628.   <!-- for example. -->
  629.   <xsl:param name="target" select="."/>
  630.   <xsl:value-of select="$target/@xreflabel"/>
  631. </xsl:template>
  632.  
  633. <!-- ==================================================================== -->
  634.  
  635. <xsl:template match="title" mode="xref">
  636.   <xsl:apply-templates/>
  637. </xsl:template>
  638.  
  639. <xsl:template match="command" mode="xref">
  640.   <xsl:call-template name="inline.boldseq"/>
  641. </xsl:template>
  642.  
  643. <xsl:template match="function" mode="xref">
  644.   <xsl:call-template name="inline.monoseq"/>
  645. </xsl:template>
  646.  
  647. <xsl:template match="*" mode="pagenumber.markup">
  648.   <xsl:message>
  649.     <xsl:text>Page numbers make no sense in HTML! (Don't use %p in templates)</xsl:text>
  650.   </xsl:message>
  651. </xsl:template>
  652.  
  653. </xsl:stylesheet>
  654. This resource fork intentionally left blank   ˇˇ